﻿<?php 
require_once("include/header.php");
require_once("maincore.php");
if (!defined("THNOJ")) die("Outside of the site");

$cache_time=100; 
//$OJ_CACHE_SHARE=true;
if (isset($_GET['cid'])) $ucid="&cid=".intval($_GET['cid']);
else $ucid="";
require_once("./include/db_info.inc.php");
?>
<div class="body-wrap nobg">
	<div class="wrapper">
		
		
		<div class="main">
			<div class="col-a1">
<?php 
//require_once("include/header.php");
$pr_flag=false;

if (isset($_GET['id'])) 
{
	$id=intval($_GET['id']);
	$sql="SELECT * FROM `problem` WHERE `defunct`='N' AND `problem_id`=".$id;
	$result=mysql_query($sql) or die(mysql_error());
		$row=mysql_fetch_object($result);
		
		echo "<title>Bài toán $row->problem_id. -- $row->title</title>";
		echo "<center><h2>Bài toán $id: $row->title</h2>";
		echo "<span class='author'>(Người viết: $row->author_id)</span><br/>";
		echo "<span class=green>Giới hạn thời gian: </span>$row->time_limit giây&nbsp;&nbsp;";
		echo "<span class=green>Giới hạn bộ nhớ: </span>".$row->memory_limit." MB";
		//if ($row->spj) echo "giây&nbsp;&nbsp;<span class=red>Special Judge</span>";
		echo "<br><span class=green>Số bài đã nộp: </span>".$row->submit."&nbsp;&nbsp;";
		//echo "<span class=green>Hoàn thành: </span>".$row->accepted."<br>"; 

		if ($MEMBER) {
			echo "[<a href='submitpage.php?id=$id'>Nộp bài</a>]";
			echo "[<a href='status.php?p=".$row->problem_id."'>Kết quả</a>]";
		}
		echo "</center>";
		
		echo "<h2>Mô tả</h2><div class=content>".$row->description."</div>";
		echo "<h2>Input</h2><div class=content>".$row->input."</div>";
		echo "<h2>Output</h2><div class=content>".$row->output."</div>";
		
		$ie6s="";
		$ie6e="";
		//if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
		{
			$ie6s="<pre>";
			$ie6e="</pre>";
		}
		
		echo "<h2>Ví dụ</h2>
			<div class='sampletest'><h3>Input</h3>
				<div class=content><span class=sampledata>".$ie6s.($row->sample_input).$ie6e."</span></div></div>";
		echo "<div class='sampletest'><h3>Output</h3>
				<div class=content><span class=sampledata>".$ie6s.($row->sample_output).$ie6e."</span></div></div>";
		//if ($pr_flag||true) 
		if (strlen($row->hint))
			echo "<h2>Lưu ý</h2>
				<div class=content><p>".nl2br($row->hint)."</p></div>";
		if ($pr_flag && strlen($row->source)) 
			echo "<h2>Mã nguồn</h2>
				<div class=content><p><a href='problemset.php?search=$row->source'>".nl2br($row->source)."</a></p></div>";
		echo "<center>";
		if ($MEMBER){
			echo "[<a href='submitpage.php?id=$id'>Nộp bài</a>]";
			echo "[<a href='status.php?p=".$row->problem_id."'>Kết quả</a>]";
		}
		echo "</center>";
	
	mysql_free_result($result);
}
else {
	//require_once("include/header.php");
	echo "<h2>Không có bài toán này</h2>";
	//require_once("include/footer.php");
	//exit(0);
}
//echo $sql;

?>
			</div>
			<div class="col-b4 qcao">
					<?php include("qcao.php");?>
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>
<?php require("include/footer.php")?>
